﻿using System.ComponentModel;
using System.Windows;

namespace ThePresenter.IO
{
	/// <summary>
	/// Provides a base interface for formats.
	/// </summary>
	public interface IFormat : INotifyPropertyChanged
	{
		#region Properties

		/// <summary>
		/// Gets the filter that is shown in the <see cref="Microsoft.Win32.OpenFileDialog"/> and <see cref="Microsoft.Win32.SaveFileDialog"/> dialogs.
		/// If is null, this format does not support writing or reading to / from file.
		/// Can be null.
		/// </summary>
		/// <value>The filter shown in the dialogs.</value>
		string Filter { get; }

		/// <summary>
		/// Gets the configuration object.
		/// Can be null.
		/// </summary>
		/// <value>The configuration object.</value>
		DependencyObject Configuration { get; }

		/// <summary>
		/// Gets a value indicating whether this format supports progress reporting.
		/// </summary>
		/// <value><c>true</c> if this format supports progress reporting; otherwise, <c>false</c>.</value>
		bool SupportsProgressReporting { get; }

		/// <summary>
		/// If <seealso cref="SupportsProgressReporting"/>, then gets the total number of slides.
		/// </summary>
		/// <value>The total slides.</value>
		int TotalSlides { get; }

		/// <summary>
		/// If <seealso cref="SupportsProgressReporting"/>, then gets the current count of processed slides.
		/// </summary>
		/// <value>The total slides.</value>
		int SlidesDone { get; }

		#endregion
	}

	public static class IFormatExtensions
	{
		#region Methods

		/// <summary>
		/// Gets a value indicating whether this format can be shown in dialog.
		/// </summary>
		/// <param name="format">The format.</param>
		/// <returns>Value indicating whether this format can be shown in dialogx.</returns>
		public static bool CanBeShownInDialog(this IFormat format)
		{
			return !string.IsNullOrEmpty(format.Filter);
		}

		#endregion
	}
}
